#include"stdio.h"
#include"stdlib.h"

char c;
char b[8];

int main()
{
    int flag  = 1;
    int maohao = 1;
    int hang = 0;
    int i = 0;
    int sum = 0;
    while((c = getchar()) != EOF)
    {
             if(c >= '0' && c <= '9')
             {
                  if(hang)
                  {
                          printf("%s %d\n",b,sum);
                          memset(b,0,sizeof(b));
                          i = 0;
                          sum = 0;
                          hang = 0;
                          maohao = 1;
                           }
                  b[i++] = c;
                  }
             else if(c == ':')
                  {
                       if(maohao)
                                 b[i++] = c;
                       maohao = 0;
                       }
             else if((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '-')
                  {
                        if(flag) sum++;
                        flag = 0;
                        }
             else 
             {
                  flag = 1;
                  hang = 1;
                  }
    }
    printf("%s %d\n",b,sum);

    return 0;
}
